/*
 * Public Credit Information Sharing Platform(PCISP).
 * Copyright (c) 2019-2020 jsxzkingdee and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 * Please visit https://www.zhengxinsoft.com if you need additional information or have any questions.
 */

package com.platform.comm;

import com.google.common.base.Strings;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;

/**
 * Description: 启动类提示信息
 *
 * @author libin created on 2020/5/16.
 */
@Slf4j
public class BaseStartUp {

    public static void logApplicationStartup(Environment env) {
        String protocol = "http";
        String ssl = "server.ssl.key-store";
        if (env.getProperty(ssl) != null) {
            protocol = "https";
        }
        String serverPort = env.getProperty("server.port");
        String contextPath = env.getProperty("server.servlet.context-path");
        if (Strings.isNullOrEmpty(contextPath)) {
            contextPath = "/";
        }
        log.info(
                "\n----------------------------------------------------------\n\t" +
                        "Application is running! API URLs:\n\t" +
                        "Local: \t\t{}://localhost:{}{}\n\t" +
                        "Profile(s): \t{}\n----------------------------------------------------------",
                protocol,
                serverPort,
                contextPath,
                env.getActiveProfiles()
        );
    }

}
